import { T_srv, Tsrv, ifs, ts, tvs, vue } from '@/services';
import { I_cmd, T_cmd } from './command';
import { N_cAutoDataQuery } from './type';

// 获取当前天和上月该天
const currentDate = new Date();
const firstDay = new Date(
  currentDate.getFullYear(),
  currentDate.getMonth() - 1,
  currentDate.getDate()
);
const lastDay = new Date();

// 计算当前天与上月该天的天数差
const daysInMonth =
  Math.ceil((lastDay.getTime() - firstDay.getTime()) / (1000 * 60 * 60 * 24)) +
  1; // 包含首尾两天

// 表格列配置
const tableColumns = () => [
  { field: 'execTime', title: '单元订单执行时间(小时)' },
  { field: 'totalWorkTime', title: '评价周期内工作日总时间(小时)' },
  { field: 'utilization', title: '单元利用率(%)' },
  { field: 'autoOrders', title: '自动化订单数' },
  { field: 'autoRacks', title: '自动化挂组数' },
  { field: 'totalOrders', title: '总订单数' },
  { field: 'totalracks', title: '总挂组数' },
  { field: 'autoRate', title: '自动化订单率(%)' },
  { field: 'autoRackRate', title: '自动化挂组率(%)' },
  { field: 'evalPeriod', title: '评价周期' }
];

// 表单配置
const formConfig = () => ({
  dateRange: {
    type: 'daterange',
    default: [firstDay, lastDay] as [Date, Date]
  },
  workDays: {
    type: 'number',
    default: daysInMonth,
    min: 1,
    max: daysInMonth
  }
});

export {
  I_cmd,
  N_cAutoDataQuery,
  T_cmd,
  T_srv,
  Tsrv,
  formConfig,
  ifs,
  tableColumns,
  ts,
  tvs,
  vue
};
